using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using TVT.Common.Exceptions;
using System.Configuration;
using TVT.BizLayer.Helpers;
using System.Data;
using TVT.Common.Helpers;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Linq;
using System.Net.Security;
using TVT.DataAccess.Repositories;
using Common.Helpers;
using TVT.BizLayer.Managers;
using MathLib;
using Common.Entities;


namespace TradeTestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                String martin = "(1.50546238039233,2.63986854788188,1.8713441726058,1.29548607954915,0.898165369477044,1.34973190551259,0.600872075419703,0.489463205353651,0.387983418552008,0.958722682647594,0.633942658275801,1.09507197501209,1.75352674518105,1.24303615751469,0.860523714456116,0.596604326468112,0.896556382339392,0.399127924580297,0.325124833226385,0.257717113097771,0.636829385532536,0.421094984858137,0.727399096300704,0.708877786398603,0.490738859171074,0.340231096051239,0.511287543690599,0.227614392353672,0.185411961419964,0.146970734153907,0.363170614467464,0.240141752052181,0.414820645479006,0.692275690657812,0.47995733902138,0.721263317176512,0.321091162286307,0.261557020092187,0.207328734196314,0.512317668060278,0.338763263089682,0.585179354520994,0.693303759612469,1.04187295164323,0.463819785411214,0.377822049252734,0.299488682029708,0.740048617875727,0.489347333239137,0.845298141214444,1.50276547212956,0.668999380113664,0.54495889285805,0.431973255412766,1.06742334455158,0.705819529253186,1.21923201698334,0.445178833637712,0.362637352910292,0.287452209559099,0.71030600872067,0.469680427414247,0.8113255458655,0.814588038580036,0.645700531649779,1.59555206818013,1.05503764313394,1.82247107131279,0.792671265803686,1.95872268264759,1.29517939518612,2.2372917167918,2.47104035070787,1.6339426582758,2.82247107131279,0.661236736910318,1.14221974177971,1.7273990963007)";
                String maria = "(1.49194225011394,2.90146931952494,2.14475126782571,1.22279264104893,0.820810884307025,1.278745326028,0.59870659123249,0.496297571936183,0.403034896819596,0.98529914545757,0.675139794055598,1.23318628147321,1.94475980508184,1.4375564923253,0.819597836950825,0.550162638161325,0.857101088148919,0.40129340876751,0.332651999028972,0.27014108407267,0.66041372940697,0.452524079939447,0.826564353532475,0.73919488081193,0.421439107703244,0.282894903896974,0.440723366407118,0.20634600104285,0.171050429034846,0.138907171655217,0.33958627059303,0.232688930919366,0.425021306678894,0.570132611362698,0.382706795244906,0.596220804347331,0.279149661881045,0.23140099245136,0.187916847452517,0.45940019257172,0.314786989141187,0.574978693321106,0.671259260771248,1.0457581139277,0.489622337536241,0.405872226635623,0.329601997337723,0.805777784704664,0.552129421940627,1.00849992065324,1.55790493337279,0.729408689235343,0.604643019999893,0.491020409847344,1.20039727091267,0.822527828228775,1.50240001083116,0.468198459103795,0.388112911800637,0.315179956959445,0.770520232138854,0.527970488191496,0.964372073447725,0.828949570965154,0.673175980892266,1.64571287486454,1.12766387399505,2.05975063500569,0.812083152547483,1.98529914545757,1.36035280491441,2.48477194168458,2.44469933802929,1.6751397940556,3.05975063500569,0.685213010858813,1.25158566021137,1.82656435353247)";
                String donna = "(1.7609314188736,2.52842205510417,1.72902463387271,1.19253156624488,0.912300349127548,1.51689145719075,0.637803390129851,0.509324489464878,0.393430399099809,1.03800674484328,0.648615424373282,1.02683705457102,1.43584357005879,0.981880733878151,0.677216360309871,0.518078296150289,0.861414272545062,0.362196609870149,0.289235846442374,0.22342176128101,0.589464605900015,0.368336561788519,0.583121547815785,0.683835450012111,0.471650515718882,0.360818063299943,0.599936017061935,0.252253530553693,0.201439664092747,0.155603135285735,0.410535394099985,0.256529728912904,0.406117741497361,0.689713462077067,0.527638722580925,0.877310494873159,0.368880452964562,0.294573298429,0.227544704333446,0.600342369049036,0.375133709298576,0.593882258502639,0.765011488962308,1.2719927087274,0.534831452837939,0.427095184632028,0.329911937122695,0.870422866970161,0.543897908225344,0.861056498323474,1.66271059595821,0.69911558264753,0.558285974517006,0.431250957512025,1.13779058161706,0.710966980330071,1.12554714634606,0.420467388820984,0.33576857925493,0.259366217163906,0.684298629227994,0.427595146177766,0.676935089655461,0.798560335907253,0.61685216038082,1.6274713507433,1.0169519861618,1.60995860238681,0.772455295666555,2.03800674484328,1.27348171507471,2.01607634388417,2.63834911389232,1.64861542437328,2.60995860238681,0.624866290701424,0.989239289313146,1.58312154781578)";

                Vector vMartin = Vector.FromString(martin);
                Vector vMaria = Vector.FromString(maria);
                Vector vDonna = Vector.FromString(donna);

                Vector martinDiff = RecognitionManager.MaleVector() - vMartin;
                Vector mariaDiff = RecognitionManager.FemaleVector() - vMaria;
                Vector donnaDiff = RecognitionManager.FemaleVector() - vDonna;

                double conMaria = (martinDiff - mariaDiff).Abs();
                double conDonna = (martinDiff - donnaDiff).Abs();

                Dictionary<FacePoint.PositionEnum, FacePoint> points = new Dictionary<FacePoint.PositionEnum,FacePoint>();
                points.Add(FacePoint.PositionEnum.LeftEye, new FacePoint(92,183));
                points.Add(FacePoint.PositionEnum.RightEye, new FacePoint(177,183));
                points.Add(FacePoint.PositionEnum.Nose, new FacePoint(135,232));
                points.Add(FacePoint.PositionEnum.Mouth, new FacePoint(136,271));
                points.Add(FacePoint.PositionEnum.HeadTop, new FacePoint(130, 91));
                points.Add(FacePoint.PositionEnum.Chin, new FacePoint(133,333));
                points.Add(FacePoint.PositionEnum.RightEar, new FacePoint(220,196));
                points.Add(FacePoint.PositionEnum.Jaw, new FacePoint(210, 271));

                Vector vector = RecognitionManager.GetEigenVector(points);
                String a = vector.ToString();
                              

                Vector vector2 = Vector.FromString(a);
                double result = RecognitionManager.CalculateEigenValue(points, true);
                Console.WriteLine(result);
                points = new Dictionary<FacePoint.PositionEnum, FacePoint>();

                points.Add(FacePoint.PositionEnum.LeftEye, new FacePoint(87, 169));
                points.Add(FacePoint.PositionEnum.RightEye, new FacePoint(172, 172));
                points.Add(FacePoint.PositionEnum.Nose, new FacePoint(127, 213));
                points.Add(FacePoint.PositionEnum.Mouth, new FacePoint(125, 252));
                points.Add(FacePoint.PositionEnum.HeadTop, new FacePoint(131, 79));
                points.Add(FacePoint.PositionEnum.Chin, new FacePoint(123, 307));
                points.Add(FacePoint.PositionEnum.RightEar, new FacePoint(209, 187));
                points.Add(FacePoint.PositionEnum.Jaw, new FacePoint(191, 243));

                result = RecognitionManager.CalculateEigenValue(points, false);
                Console.WriteLine(result);
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                ExceptionLogger.HandleException(ex);
            }
        }
      
    }
}
